/*
* 今日数据分析
* */

$(function () {
    getTodayInfo();

    var time = setInterval(function() {
        getTodayInfo();
    }, 5 * 60 * 1000);

});

function getTodayInfo() {
    //获取今日数据分析数据
    $.ajax({
        url: "/hospital/total/index",
        dataType: "json"
    }).done(function(data) {
        console.log('Data: ', data);
        rollNum("listedCompany", 0, data.result.todayOutpatient);
        // rollNum("listedSecurity", 0, data.listed_securities_total);
        rollNum("totalMarket", 0, data.result.todayAdmitte);
        // rollNum("circulationMarket", 0, data.circulation_market_value);
        rollNum("shRatio", 0, data.result.todayRecord);
        rollNum("szRatio", 0, data.result.todayCommon);
    }).fail(function(jqXHR, textStatus) {
        console.log("Ajax Error: ", textStatus);
    });
}

//数字变化特效
function rollNum(elId, startVal, endVal, decimalNum) {
    let n = decimalNum || 0;
    let countUp = new CountUp(elId, startVal, endVal, n, 2.5, {
        useEasing: true,
        useGrouping: true,
        separator: ',',
        decimal: '.'
    });
    if(!countUp.error) {
        countUp.start();
    }else {
        // console.log(countUp.error);
    }
}